﻿using MediatR;
using Service.Auth.Domain.Events;
using Service.Auth.Api.Application.Command;
using Service.Auth.Model.Model.RequestDto.UserSystem;

namespace Service.Auth.Api.Application.DomainEventHandlers;


/// <summary>
/// 
/// </summary>
public class RoleChangeInfoDomainEventHandler(IMediator mediator)
    : INotificationHandler<RoleChangeInfoDomainEvent>
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="notification"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    public async Task Handle(RoleChangeInfoDomainEvent notification, CancellationToken cancellationToken)
    {
        var command = new UpdateUserSystemRoleNumByRoleIdCommand(new UpdateUserSystemRoleNumByRoleIdDto()
        {
            RoleId = notification.RoleId,
            RoleNum = notification.RoleNum,
            RoleName = notification.RoleName
        });
        await mediator.Send(command, cancellationToken);
    }
}
